#include "opencv2/opencv.hpp"
#include <opencv2/xfeatures2d.hpp>
#include <vector>
#include<iostream>
#include <fstream>
using namespace std;
using namespace cv;

void main()
{     

    //定义SIFT特征检测类对象
    SiftFeatureDetector siftDetector;//SIFT=SiftFeatureDetector=SiftDescriptorExtractor    别名//定义KeyPoint变量
 
	ifstream fin("../doc/undistortdata.txt"); /* 标定所用图像文件的路径 */
	int image_count=0;  /* 图像数量 */
	string filename;
	while (getline(fin,filename))
	{
		image_count++;		
		// 用于观察检验输出
		std::cout<<"image_count = "<<image_count<<endl;		
		cv::Mat imgInput=imread(filename);

		if(imgInput.empty())
			return 0;
		vector<KeyPoint>keyPoints1;
		siftDetector.detect(imgInput, keyPoints1);
		
		filename = "../img/sift_"+to_string(image_count)+".sift";
		
		ofstream fout(filename);  /* 保存标定结果的文件 */	
		
		fout<<keyPoints1<<endl;  
		
	}
    
}